package ch.exm.storm.query.inmemory;

import java.util.Collection;
import java.util.Map;

import ch.exm.storm.conditions.Condition;
import ch.exm.storm.query.AbstractQueryPlan;
import ch.exm.storm.query.join.Joiner;
import ch.exm.storm.query.selection.Selection;

public class InMemoryQueryPlan extends AbstractQueryPlan {

	private Map<Class<?>, Collection<?>> workingSet;
	
	private Condition condtion;
	private Selection selection;
	
	InMemoryQueryPlan(Map<Class<?>, Collection<?>> workingSet, Selection selection, Condition condtion) {
		this.workingSet = workingSet;
		this.condtion = condtion;
		this.selection = selection;
	}
	
	@Override
	public Collection<?> execute() {
		return applySelection(applyConditions(Joiner.doJoin(workingSet), condtion), selection);
	}
}
